/**
 * @description 数据库实例 文件
 * @author 宫彦胜
 */

const Sequelize = require('sequelize')
const { isPro } = require('../util/env')
const { MYSQL_CONF } = require('../conf/db')
const { username, password, host, database, dialect } = MYSQL_CONF

const conf = {
  host,
  dialect
  
}

if(isPro){
  conf.pool = {
    max: 5, // 最多连接数
    min: 0, //最少连接数
    
    idle: 10000, //连接空闲多久会被释放
  }
}

// 创建seq 实例
const seq = new Sequelize(database, username, password, conf)

// 暴露模块儿的实例
module.exports = seq